package bank.service.spring.employee;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import bank.model.dao.EmployeeDAO;
import bank.model.vo.Employee;

public class AddEmployeeFormController implements Controller {
	private EmployeeDAO employeeDAO;
	public AddEmployeeFormController(EmployeeDAO employeeDAO) {
		super();
		this.employeeDAO = employeeDAO;
		
	}
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		Employee employee = new Employee(0,request.getParameter("firstName"),request.getParameter("lastName"),
				request.getParameter("subName"),(Integer)request.getSession().getAttribute("employee_dept_id"),2);
		employeeDAO.addEmployee(employee);
		
		return new ModelAndView("employee/Done");
	}
}
